package com.jnu.hc.jnuhcdoccms.controller;

import com.jnu.hc.jnuhcdoccms.dto.OrdersPageRequestDto;
import com.jnu.hc.jnuhcdoccms.dto.OrdersPageResponseDto;
import com.jnu.hc.jnuhcdoccms.dto.ResponseObject;
import com.jnu.hc.jnuhcdoccms.service.OrdersService;
import com.jnu.hc.jnuhcusercms.domain.Orders;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;


    @RestController
    @RequestMapping("/orders")
    public class OrdersController {

        @Autowired
        private OrdersService ordersService;

        @RequestMapping("/listOrders")
        public OrdersPageResponseDto listOrders(@RequestBody OrdersPageRequestDto request) {
            return ordersService.listOrders(request);
        }

        @RequestMapping("/getOrdersById")
        public Orders getOrdersById(@RequestBody Orders orders) {
            System.out.println("debug");
            return ordersService.getOrdersById(orders.getOrderId());
        }

        @RequestMapping("/updateOrdersState")
        public int updateOrdersState(@RequestBody Orders orders) {
            return ordersService.updateOrdersState(orders);
        }
    }

